package seiacpjava_a2.datastructures;

import seiacpjava_a2.datastructures.hashtable.HashTable;
import seiacpjava_a2.datastructures.hashtable.HashTableStrategy;
import seiacpjava_a2.datastructures.hashtable.ModuloStrategy;
import seiacpjava_a2.datastructures.hashtable.ReflexiveStrategy;
import seiacpjava_a2.datastructures.tree.BinarySearchTreeRecursive;

public class DataStructureFactory {

	public static final String HASHTABLE = "hashtable";
	public static final String BIN_SRCH_TREE_RECURSIVE = "bst_recursive";
	
	/**
	 * 
	 * @param dataStructureName
	 * @return datastructure corresponding to the dataStructureName
	 * @throws IllegalArgumentException if the dataStructureName doesn't exist
	 */
	public static DataStructure createByName(String dataStructureName) {
		DataStructure dataStructure = null;
		switch (dataStructureName) {
		case BIN_SRCH_TREE_RECURSIVE:
			dataStructure = createBinarySearchTreeRecursive();
			break;
		case HASHTABLE:
			//collection = createHashTable();
			break;
		default:
			throw new IllegalArgumentException(String.format("No DataStructure exists with the name %s", dataStructure));
		}
		return dataStructure;
	}
 	
	public static DataStructure createBinarySearchTreeRecursive() {
		return new BinarySearchTreeRecursive();
	}
	
	public static DataStructure createHashTableWithModuloStrategy(int [] items){
		
		HashTableStrategy strategy = new ModuloStrategy();
		return new HashTable(items, strategy);
		
	}
	
	public static DataStructure createHashTableWithReflexiveStrategy(int [] items){
		
		HashTableStrategy strategy = new ReflexiveStrategy();
		return new HashTable(items, strategy);
		
	}
	
	/*
	public static Collection createHashTable() {
		return new 
	}
	*/
}
